home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
Issue34
/
clinic
/
LoopyU.pas
< prev
Wrap
Pascal/Delphi Source File
|
1998-02-06
|
4KB
|
163 lines
unit LoopyU;
interface
uses
WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
GroupBox1: TGroupBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
ListBox1: TListBox;
RadioGroup1: TRadioGroup;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
public
EditList: TList;
EditArray: array[1..3] of TEdit;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure ListControls(Control: TWinControl; List: TStrings);
var
Loop: Integer;
begin
for Loop := 0 to Control.ControlCount - 1 do
begin
with Control.Controls[Loop] do
List.Add(Format('%s: %s', [Name, ClassName]));
if Control.Controls[Loop] is TWinControl then
ListControls(TWinControl(Control.Controls[Loop]), List)
end
end;
procedure ListComponents(Component: TComponent; List: TStrings);
var
Loop: Integer;
begin
for Loop := 0 to Component.ComponentCount - 1 do
begin
with Component.Components[Loop] do
List.Add(Format('%s: %s', [Name, ClassName]));
ListComponents(Component.Components[Loop], List)
end
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Loop: Integer;
begin
{ EditArray[1] := Edit1;
EditArray[2] := Edit2;
EditArray[3] := Edit3; }
for Loop := 1 to 3 do
EditArray[Loop] := FindComponent('Edit' + IntToStr(Loop)) as TEdit;
EditList := TList.Create;
{ EditList.Add(Edit1);
EditList.Add(Edit2);
EditList.Add(Edit3); }
for Loop := 1 to 3 do
EditList.Add(FindComponent('Edit' + IntToStr(Loop)));
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
EditList.Free;
EditList := nil
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Loop: Integer;
Msg: String;
begin
Msg := '';
for Loop := 1 to 3 do
Msg := Msg + EditArray[Loop].Text;
ShowMessage(Msg)
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Loop: Integer;
Msg: String;
begin
Msg := '';
for Loop := 0 to EditList.Count - 1 do
Msg := Msg + TEdit(EditList[Loop]).Text;
ShowMessage(Msg)
end;
procedure TForm1.Button3Click(Sender: TObject);
var
Loop: Integer;
Msg: String;
begin
Msg := '';
for Loop := 0 to ComponentCount - 1 do
if Components[Loop] is TEdit then
Msg := Msg + TEdit(Components[Loop]).Text;
ShowMessage(Msg)
end;
procedure TForm1.Button4Click(Sender: TObject);
procedure LoopEdits(Ctl: TWinControl; var Msg: String);
var
Loop: Integer;
begin
for Loop := 0 to Ctl.ControlCount - 1 do
begin
if Ctl.Controls[Loop] is TEdit then
Msg := Msg + TEdit(Ctl.Controls[Loop]).Text;
if Ctl.Controls[Loop] is TWinControl then
LoopEdits(TWinControl(Ctl.Controls[Loop]), Msg)
end
end;
var
Msg: String;
begin
Msg := '';
LoopEdits(Self, Msg);
ShowMessage(Msg)
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
ListBox1.Items.Clear;
ListControls(Self, ListBox1.Items)
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
ListBox1.Items.Clear;
ListComponents(Self, ListBox1.Items)
end;
end.